package com.sina.weibo;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.Toast;
import com.sina.weibo.models.MBlog;
import com.sina.weibo.models.User;
import com.sina.weibo.view.MBlogListItemView;
import com.sina.weibo.view.MainListItemView;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class FavoriteActivity extends ListBaseActivity
{
  private final int REFRESH_AFTER_DELETE_FAVE = 0;
  WeiboListAdapter adapter;
  private String blogId = null;
  Handler handler;
  private ListView mLvFav;
  private boolean mPrefShowPicture = 1;
  private int mReadMode;
  private int mReloadCount = 0;

  public FavoriteActivity()
  {
    FavoriteActivity.1 local1 = new FavoriteActivity.1(this);
    this.handler = local1;
  }

  protected void doItemMenu(String paramString)
  {
    int i = this.mExpectItem - 1;
    this.mExpectItem = i;
    Resources localResources = getResources();
    String str1 = localResources.getString(2131427510);
    if (paramString.equals(str1))
    {
      List localList1 = this.mList;
      int j = this.mExpectItem;
      MBlog localMBlog1 = (MBlog)localList1.get(j);
      Intent localIntent1 = Utils.forwardMBlog(this, localMBlog1);
      startActivity(localIntent1);
    }
    while (true)
    {
      return;
      String str2 = localResources.getString(2131427517);
      MBlog localMBlog2;
      if (paramString.equals(str2))
      {
        List localList2 = this.mList;
        int k = this.mExpectItem;
        localMBlog2 = (MBlog)localList2.get(k);
        try
        {
          RPCHelper localRPCHelper1 = RPCHelper.getInstance(getApplication());
          User localUser1 = StaticInfo.mUser;
          String str3 = localMBlog2.favid;
          String str4 = localMBlog2.mblogid;
          if (!localRPCHelper1.deleteFavMBlog(localUser1, str3, str4))
            break label212;
          String str5 = this.mCacheDir;
          User localUser2 = StaticInfo.mUser;
          Utils.cleanFavoriteListFile(str5, localUser2);
          Message localMessage = new Message();
          localMessage.what = 0;
          boolean bool1 = this.handler.sendMessage(localMessage);
        }
        catch (RPCHelper.HttpException localHttpException1)
        {
        }
        continue;
        label212: String str6 = getString(2131427485);
        Toast.makeText(this, str6, 0).show();
        continue;
      }
      String str7 = localResources.getString(2131427514);
      if (paramString.equals(str7))
      {
        List localList3 = this.mList;
        int m = this.mExpectItem;
        localMBlog2 = (MBlog)localList3.get(m);
        try
        {
          RPCHelper localRPCHelper2 = RPCHelper.getInstance(getApplication());
          User localUser3 = StaticInfo.mUser;
          String str8 = localMBlog2.favid;
          String str9 = localMBlog2.mblogid;
          if (!localRPCHelper2.deleteFavMBlog(localUser3, str8, str9))
            continue;
          boolean bool2 = this.mList.remove(localMBlog2);
          int[] arrayOfInt1 = StaticInfo.mTotals;
          int n = arrayOfInt1[5] - 1;
          arrayOfInt1[5] = n;
          this.mExpectItem = 0;
          ((WeiboListAdapter)this.mLvFav.getAdapter()).refresh();
        }
        catch (RPCHelper.HttpException localHttpException2)
        {
        }
        continue;
      }
      String str10 = localResources.getString(2131427515);
      if (paramString.equals(str10))
      {
        List localList4 = this.mList;
        int i1 = this.mExpectItem;
        localMBlog2 = (MBlog)localList4.get(i1);
        try
        {
          RPCHelper localRPCHelper3 = RPCHelper.getInstance(getApplication());
          User localUser4 = StaticInfo.mUser;
          String str11 = localMBlog2.mblogid;
          if (!localRPCHelper3.deleteMBlog(localUser4, str11))
            continue;
          boolean bool3 = this.mList.remove(localMBlog2);
          int[] arrayOfInt2 = StaticInfo.mTotals;
          int i2 = arrayOfInt2[0] - 1;
          arrayOfInt2[0] = i2;
          this.mExpectItem = 0;
          ((WeiboListAdapter)this.mLvFav.getAdapter()).refresh();
        }
        catch (RPCHelper.HttpException localHttpException3)
        {
        }
        continue;
      }
      String str12 = localResources.getString(2131427511);
      if (paramString.equals(str12))
      {
        List localList5 = this.mList;
        int i3 = this.mExpectItem;
        MBlog localMBlog3 = (MBlog)localList5.get(i3);
        String str13 = localMBlog3.mblogid;
        String str14 = localMBlog3.uid;
        Intent localIntent2 = Utils.simpleComment(this, str13, str14);
        startActivity(localIntent2);
        continue;
      }
      String str15 = localResources.getString(2131427518);
      if (paramString.equals(str15))
      {
        Intent localIntent3 = new Intent(this, UserInfoActivity2.class);
        List localList6 = this.mList;
        int i4 = this.mExpectItem;
        MBlog localMBlog4 = (MBlog)localList6.get(i4);
        String str16 = localMBlog4.uid;
        Intent localIntent4 = localIntent3.putExtra("uid", str16);
        String str17 = localMBlog4.nick;
        Intent localIntent5 = localIntent3.putExtra("nick", str17);
        String str18 = StaticInfo.mUser.uid;
        Intent localIntent6 = localIntent3.putExtra("myuid", str18);
        boolean bool4 = localMBlog4.vip;
        Intent localIntent7 = localIntent3.putExtra("vip", bool4);
        startActivity(localIntent3);
        continue;
      }
      String str19 = localResources.getString(2131427508);
      if (paramString.equals(str19))
      {
        List localList7 = this.mList;
        int i5 = this.mExpectItem;
        localMBlog2 = (MBlog)localList7.get(i5);
        try
        {
          String str20 = this.mCacheDir;
          String str21 = localMBlog2.portrait;
          String str22 = Utils.checkCache(str20, str21);
          boolean bool5 = new File(str22).delete();
          ((WeiboListAdapter)this.mLvFav.getAdapter()).refresh();
        }
        catch (NullPointerException localNullPointerException1)
        {
        }
        continue;
      }
      String str23 = localResources.getString(2131427507);
      if (paramString.equals(str23))
      {
        List localList8 = this.mList;
        int i6 = this.mExpectItem;
        localMBlog2 = (MBlog)localList8.get(i6);
        try
        {
          String str24 = this.mCacheDir;
          String str25 = localMBlog2.pic;
          String str26 = Utils.checkCache(str24, str25);
          boolean bool6 = new File(str26).delete();
          ((WeiboListAdapter)this.mLvFav.getAdapter()).refresh();
        }
        catch (NullPointerException localNullPointerException2)
        {
        }
        continue;
      }
      if (paramString.startsWith("@"))
      {
        Intent localIntent8 = new Intent(this, UserInfoActivity2.class);
        String str27 = paramString.substring(1);
        Intent localIntent9 = localIntent8.putExtra("nick", str27);
        String str28 = StaticInfo.mUser.uid;
        Intent localIntent10 = localIntent8.putExtra("myuid", str28);
        Intent localIntent11 = localIntent8.putExtra("vip", 0);
        startActivity(localIntent8);
        continue;
      }
      if (paramString.startsWith("#"))
      {
        int i7 = paramString.length() - 1;
        String str29 = paramString.substring(1, i7);
        this.mList = null;
        continue;
      }
      Uri localUri = Uri.parse(paramString);
      Intent localIntent12 = new Intent("android.intent.action.VIEW", localUri);
      startActivity(localIntent12);
    }
  }

  protected BaseAdapter getAdapter()
  {
    if (this.adapter == null)
    {
      WeiboListAdapter localWeiboListAdapter1 = new WeiboListAdapter();
      this.adapter = localWeiboListAdapter1;
    }
    if (this.adapter != null);
    for (WeiboListAdapter localWeiboListAdapter2 = this.adapter; ; localWeiboListAdapter2 = null)
      return localWeiboListAdapter2;
  }

  protected List<CharSequence> getMenuContent()
  {
    Resources localResources = getResources();
    ArrayList localArrayList = new ArrayList();
    String str1 = localResources.getString(2131427510);
    boolean bool1 = localArrayList.add(str1);
    String str2 = localResources.getString(2131427511);
    boolean bool2 = localArrayList.add(str2);
    String str3 = localResources.getString(2131427517);
    boolean bool3 = localArrayList.add(str3);
    String str4 = localResources.getString(2131427518);
    boolean bool4 = localArrayList.add(str4);
    return localArrayList;
  }

  protected Object[] getMessages(int paramInt1, int paramInt2)
  {
    try
    {
      RPCHelper localRPCHelper = RPCHelper.getInstance(getApplication());
      User localUser = StaticInfo.mUser;
      int i = MainTabActivity.mPrefPictureSize;
      Object[] arrayOfObject = localRPCHelper.getFavMBlogList(localUser, i, paramInt1, paramInt2);
      localObject = StaticInfo.mTotals;
      int j = 5;
      if (arrayOfObject[0] != 0);
      for (int k = ((Integer)arrayOfObject[0]).intValue(); ; k = 0)
      {
        localObject[j] = k;
        localObject = arrayOfObject;
        return localObject;
      }
    }
    catch (RPCHelper.HttpException localHttpException)
    {
      while (true)
        Object localObject = null;
    }
  }

  protected void handleListItemClickEvent(int paramInt)
  {
    switch (paramInt)
    {
    default:
    case 0:
    case 1:
    }
    while (true)
    {
      return;
      List localList = getMenuContent();
      showItemMenu(localList);
      continue;
      int i = this.mExpectItem - 1;
      MBlog localMBlog = (MBlog)this.mList.get(i);
      Intent localIntent1 = new Intent();
      Context localContext = getApplicationContext();
      Intent localIntent2 = localIntent1.setClass(localContext, DetailWeiboActivity.class).putExtra("KEY_MBLOG", localMBlog);
      User localUser = StaticInfo.mUser;
      Intent localIntent3 = localIntent2.putExtra("KEY_MUSR", localUser);
      startActivity(localIntent3);
    }
  }

  protected void handleTaskResult(List<?> paramList, String paramString)
  {
    if ((paramList != null) && (paramList.size() > 0))
      if (this.mList == null)
      {
        this.mList = paramList;
        List localList1 = this.mList;
        String str1 = this.mCacheDir;
        User localUser1 = StaticInfo.mUser;
        Utils.saveFavoriteListFile(localList1, str1, localUser1);
        if (this.mList.size() <= 0)
        {
          String str2 = this.mCacheDir;
          User localUser2 = StaticInfo.mUser;
          Utils.cleanFavoriteListFile(str2, localUser2);
        }
      }
    while (true)
    {
      return;
      label97: MBlog[] arrayOfMBlog2;
      int i;
      if (this.mBeReload)
      {
        this.mList = null;
        this.mList = paramList;
        List localList2 = this.mList;
        MBlog[] arrayOfMBlog1 = new MBlog[0];
        arrayOfMBlog2 = (MBlog[])localList2.toArray(arrayOfMBlog1);
        FavoriteActivity.2 local2 = new FavoriteActivity.2(this);
        Arrays.sort(arrayOfMBlog2, local2);
        ArrayList localArrayList = new ArrayList();
        this.mList = localArrayList;
        i = 0;
      }
      while (true)
      {
        int j = arrayOfMBlog2.length;
        if (i >= j)
        {
          List localList3 = this.mList;
          String str3 = this.mCacheDir;
          User localUser3 = StaticInfo.mUser;
          Utils.saveFavoriteListFile(localList3, str3, localUser3);
          break;
          boolean bool1 = this.mList.addAll(paramList);
          break label97;
        }
        List localList4 = this.mList;
        MBlog localMBlog = arrayOfMBlog2[i];
        boolean bool2 = localList4.add(localMBlog);
        i += 1;
      }
      if (StaticInfo.mUser != null)
      {
        if (paramList == null)
        {
          if (paramString == null)
            break label318;
          Toast.makeText(this, paramString, 0).show();
        }
        while (true)
        {
          if ((this.mList != null) && (this.mList.size() != 0))
            break label338;
          String str4 = this.mCacheDir;
          User localUser4 = StaticInfo.mUser;
          List localList5 = Utils.loadFavoriteListFile(str4, localUser4);
          this.mList = localList5;
          break;
          label318: String str5 = getString(2131427376);
          Toast.makeText(this, str5, 0).show();
        }
        label338: continue;
      }
      String str6 = getString(2131427402);
      Toast.makeText(this, str6, 0).show();
    }
  }

  protected void handleTitleBarEvent(int paramInt)
  {
    switch (paramInt)
    {
    default:
    case 0:
    case 1:
    }
    while (true)
    {
      return;
      Intent localIntent1 = new Intent(this, MainTabActivity.class);
      Intent localIntent2 = localIntent1.putExtra("MODE_KEY", 0);
      Intent localIntent3 = localIntent1.setAction("com.sina.weibo.action.go_back_to_home");
      startActivity(localIntent1);
      finish();
      continue;
      finish();
    }
  }

  protected void loadCache()
  {
    loadCache(0);
  }

  protected void loadCache(int paramInt)
  {
    String str = this.mCacheDir;
    User localUser = StaticInfo.mUser;
    List localList = Utils.loadFavoriteListFile(str, localUser);
    this.mList = localList;
  }

  protected void loadMore(int paramInt)
  {
    reloadBegine(0);
    this.mExpectItem = paramInt;
    ListBaseActivity.FetchDataTask localFetchDataTask1 = new ListBaseActivity.FetchDataTask(this);
    this.mTask = localFetchDataTask1;
    int i = this.mPage + 1;
    this.mPage = i;
    ListBaseActivity.FetchDataTask localFetchDataTask2 = this.mTask;
    String[] arrayOfString = new String[1];
    String str = String.valueOf(this.mPage);
    arrayOfString[0] = str;
    AsyncTask localAsyncTask = localFetchDataTask2.execute(arrayOfString);
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    String str1 = getString(2131427528);
    String str2 = getString(2131427516);
    String str3 = getString(2131427368);
    setTitleBar(1, str1, str2, str3);
    ListView localListView = this.mlvBase;
    this.mLvFav = localListView;
    String str4 = getString(2131427516);
    if (StaticInfo.mUser == null);
    for (String str5 = null; ; str5 = StaticInfo.mUser.nick)
    {
      setAppTitle(str4, str5);
      return;
    }
  }

  public boolean onCreateOptionsMenu(Menu paramMenu)
  {
    getMenuInflater().inflate(2131558404, paramMenu);
    return true;
  }

  public boolean onOptionsItemSelected(MenuItem paramMenuItem)
  {
    switch (paramMenuItem.getItemId())
    {
    default:
    case 2131624250:
    }
    while (true)
    {
      return false;
      Intent localIntent1 = new Intent(this, MainTabActivity.class);
      Intent localIntent2 = localIntent1.setFlags(67108864);
      startActivity(localIntent1);
    }
  }

  protected void onPause()
  {
    super.onPause();
    if ((!this.mTaskFree) && (this.mTask != null) && (!this.mTask.isCancelled()))
    {
      this.mTaskFree = 1;
      boolean bool = this.mTask.cancel(1);
    }
  }

  public boolean onPrepareOptionsMenu(Menu paramMenu)
  {
    return true;
  }

  protected void onResume()
  {
    int i = getSharedPreferences("readmode", 0).getInt("readmode", 0);
    if (this.mReadMode != i)
    {
      this.mReadMode = i;
      this.adapter.notifyDataSetChanged();
    }
    super.onResume();
    this.mLvFav.setVisibility(4);
    String str = this.mCacheDir;
    User localUser = StaticInfo.mUser;
    List localList = Utils.loadFavoriteListFile(str, localUser);
    this.mList = localList;
    if (this.mList == null)
      reloadList();
    while (true)
    {
      return;
      this.adapter.notifyDataSetChanged();
      this.mLvFav.setFocusable(1);
      this.mLvFav.setFocusableInTouchMode(1);
      this.mLvFav.setVisibility(0);
    }
  }

  protected void reloadList()
  {
    reloadBegine(1);
    this.mBeReload = 1;
    this.mPage = 1;
    this.mNewCount = 0;
    if (this.mTaskFree)
    {
      String str = String.valueOf(this.mPage);
      ListBaseActivity.FetchDataTask localFetchDataTask1 = new ListBaseActivity.FetchDataTask(this);
      this.mTask = localFetchDataTask1;
      ListBaseActivity.FetchDataTask localFetchDataTask2 = this.mTask;
      String[] arrayOfString = new String[1];
      arrayOfString[0] = str;
      AsyncTask localAsyncTask = localFetchDataTask2.execute(arrayOfString);
    }
    this.mExpectItem = 1;
  }

  protected void saveListCache(int paramInt, List<?> paramList)
  {
    List localList = this.mList;
    String str = this.mCacheDir;
    User localUser = StaticInfo.mUser;
    Utils.saveFavoriteListFile(localList, str, localUser);
  }

  protected void setContentView()
  {
    setView(2130903060);
  }

  class WeiboListAdapter extends BaseAdapter
  {
    public WeiboListAdapter()
    {
    }

    public int getCount()
    {
      if (FavoriteActivity.this.mList == null);
      for (int i = 0; ; i = FavoriteActivity.this.mList.size() + 2)
        return i;
    }

    public Object getItem(int paramInt)
    {
      return Integer.valueOf(paramInt);
    }

    public long getItemId(int paramInt)
    {
      return paramInt;
    }

    public View getView(int paramInt, View paramView, ViewGroup paramViewGroup)
    {
      paramInt += -1;
      Object localObject1;
      if (paramInt == -1)
        localObject1 = FavoriteActivity.this.getReloadView();
      while (true)
      {
        return localObject1;
        int i = FavoriteActivity.this.mList.size();
        if (paramInt == i)
        {
          localObject1 = FavoriteActivity.this.getLoadMoreView();
          int j = FavoriteActivity.this.mList.size();
          int k = StaticInfo.mTotals[5];
          if (j >= k)
          {
            ((View)localObject1).setVisibility(4);
            continue;
          }
          ((View)localObject1).setVisibility(0);
          continue;
        }
        int m = 1;
        int n = 0;
        if (paramView == null)
        {
          FavoriteActivity localFavoriteActivity1 = FavoriteActivity.this;
          ListView localListView1 = FavoriteActivity.this.mLvFav;
          MBlog localMBlog1 = (MBlog)FavoriteActivity.this.mList.get(paramInt);
          int i1 = FavoriteActivity.this.mReadMode;
          localObject1 = new MBlogListItemView(localFavoriteActivity1, localListView1, localMBlog1, m, n, 0, 0, i1);
          continue;
        }
        localObject1 = paramView;
        try
        {
          MainListItemView localMainListItemView = (MainListItemView)localObject1;
          Object localObject2 = FavoriteActivity.this.mList.get(paramInt);
          int i2 = FavoriteActivity.this.mReadMode;
          localMainListItemView.update(localObject2, m, n, 0, i2);
        }
        catch (Exception localException)
        {
          FavoriteActivity localFavoriteActivity2 = FavoriteActivity.this;
          ListView localListView2 = FavoriteActivity.this.mLvFav;
          MBlog localMBlog2 = (MBlog)FavoriteActivity.this.mList.get(paramInt);
          int i3 = FavoriteActivity.this.mReadMode;
          localObject1 = new MBlogListItemView(localFavoriteActivity2, localListView2, localMBlog2, m, n, 0, 0, i3);
        }
      }
    }

    public int getViewTypeCount()
    {
      if (FavoriteActivity.this.mList == null);
      for (int i = 1; ; i = 4)
        return i;
    }

    public void refresh()
    {
      notifyDataSetChanged();
    }
  }
}

/* Location:           D:\Program Files\eclipse\apktool-r01-3\新浪微博\classes.dex.dex2jar.jar
 * Qualified Name:     com.sina.weibo.FavoriteActivity
 * JD-Core Version:    0.6.0
 */